package com.alvinlkk.basic.chapter21;

import java.util.concurrent.TimeUnit;

//后台进程在不执行finally子句的情况下就会终止run方法
class ADaemon implements Runnable {

    @Override
    public void run() {
        System.out.println("ADaemon starting ----");
        try {
            TimeUnit.SECONDS.sleep(1);
        } catch (InterruptedException e) {
            e.printStackTrace();
        } finally {
            System.out.println("This should always run?");
        }
    }
}

public class DaemonsDontRunFinally {
    public static void main(String[] args) {
        Thread t = new Thread(new ADaemon());
        t.setDaemon(true);
        t.start();
    }
}
